wayland: Move additional pointer buttons after the old 4-7 scrolling ones
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 16 Nov 2015 11:51:42 +0000 (12:51 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 17 Nov 2015 21:41:22 +0000 (22:41 +0100)
We were using that range for the extra buttons after left/right/middle,
while this is harmless for clients not handling extra buttons (we
used to translate those button events into scroll events in x11 anyway)
this will be unexpected for clients that do handle additional mouse
buttons themselves (eg. back/forward buttons present in some mice).

In order to remain compatible with X11, those need to be assigned from
button 8 onwards.

Also, include input.h, and stop using magic numbers here.

https://bugzilla.gnome.org/show_bug.cgi?id=758072

gdk/wayland/gdkdevice-wayland.c

index 84a1167fdea426b0881aedf644b94bd289efe6d9..157630f34f917a3c5c483ee5b0048c4f13722893 100644 (file)
 
 #include <xkbcommon/xkbcommon.h>
 
+#include <linux/input.h>
+
 #include <sys/time.h>
 #include <sys/mman.h>
 
+#define BUTTON_BASE (BTN_LEFT - 1) /* Used to translate to 1-indexed buttons */
+
 typedef struct _GdkWaylandTouchData GdkWaylandTouchData;
 
 struct _GdkWaylandTouchData
@@ -1018,14 +1022,18 @@ pointer_handle_button (void              *data,
 
   switch (button)
     {
-    case 273:
-      gdk_button = 3;
+    case BTN_LEFT:
+      gdk_button = GDK_BUTTON_PRIMARY;
+      break;
+    case BTN_MIDDLE:
+      gdk_button = GDK_BUTTON_MIDDLE;
       break;
-    case 274:
-      gdk_button = 2;
+    case BTN_RIGHT:
+      gdk_button = GDK_BUTTON_SECONDARY;
       break;
     default:
-      gdk_button = button - 271;
+       /* For compatibility reasons, all additional buttons go after the old 4-7 scroll ones */
+      gdk_button = button - BUTTON_BASE + 4;
       break;
     }